<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../js/cookie.js"></script>
    <script src="../js/ajax.js"></script>
    <script src="../js/interface.js"></script>
</head>
<body>
    <script>
        
        // Promise.race  
        // Promise.all
        
        // var pro = Promise.all([
        //     isExistUser({user:'zkl'}),
        //     isExistPhone({phone:120}),
        //     isExistEmail({email:"1231243qwewqr@qqc.com"})
        // ])

        // pro.then(res=>{
        //     console.log(res)
        // }).catch(err=>{
        //     console.log(err)
        // })

        // Promise 判断请求超时 
        function timeout(delay=0){
            return new Promise(function(resolve,reject){
                setTimeout(()=>{
                    reject({status:false,detail:"请求超时"})
                },delay)
            })
        }

        Promise.race([
            getAllGrade(),
            timeout(1), // 50ms 没有请求成功就超时 
            
        ]).then(res=>{
            console.log("请求成功 - ", res)
        }).catch(err=>{
            console.log("请求失败 - ", err)
        })

        // Promise.race([
        //     getAllGrade(),
        //     login({user:"zkl",pass:"abc123"}),
            
        // ]).then(res=>{
        //     console.log("请求成功 - ", res)
        // }).catch(err=>{
        //     console.log("请求失败 - ", err)
        // })

    </script>
</body>
</html>